void main() {
  //加强可读性
  Person person = Person(name: '张三');
  print(person.name);
  print(person.age);

  print('======================');
  Teacher teacher = Teacher(name: '李四', subject: '语文');
  print(teacher.name);
  print(teacher.age);
  print(teacher.subject);
}

class Person {
  //必填参数
  String name;
  //可选参数
  int? age;

  // 定义构造函数，升级成可选命名参数，必传参数需要添加 required 关键字
  Person({required this.name, this.age = 20});
}

class Teacher extends Person {
  //必填参数
  String subject;

  // 定义构造函数，升级成可选命名参数
  Teacher({required this.subject, required super.name, super.age});
}
